/**
 * 
 */
package view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

/**
 * @author dave
 *
 */
public class RegistersPanel extends JPanel {
	private static final long serialVersionUID = 1L;
	int register1, register2, register3, register4;

	public RegistersPanel(){
		this.setLayout(new GridLayout(2, 2, 8, 8));
		initRegisters();
		updateAddRegisters();
	}
	
	private void initRegisters(){
		register1=0;
		register2=0;
		register3=0;
		register4=0;
	}
	
	public void updateAddRegisters(){
		this.removeAll();
		for(int i=1;i<5;i++){
			JLabel myLabel=new JLabel("r"+i+" | val: "+getRegisterValue(i), SwingConstants.CENTER);
			myLabel.setBorder(BorderFactory.createLineBorder(Color.black));
			myLabel.setBackground(Color.WHITE);
			myLabel.setOpaque(true);
			myLabel.setPreferredSize(new Dimension(150,30));
			myLabel.setFont(new Font("Serif", Font.PLAIN, 12));
			this.add(myLabel);
		}
	}
	
	public int getRegisterValue(int register){
		if(register==1){
			return register1;
		}
		if(register==2){
			return register2;
		}
		if(register==3){
			return register3;
		}
		if(register==4){
			return register4;
		}
		return 0;
	}
}
